<template>
<el-button type="primary" @click="logOut">退出</el-button>
</template>

<script setup>
import {ElMessage} from "element-plus";
import router from "@/router";

const checkAuth = ()=>{
  const role = localStorage.getItem('role');
  if(role===null){
    ElMessage.error('未登录，请重新登录');
    router.push('/login');
    return;
  }
  if(!(role==='高级会员'||role==='正式会员')){
    ElMessage.error('您不是会员，请重新登录');
    router.push('/login');
  }
}
checkAuth();

const logOut = ()=>{
  localStorage.removeItem('role');
  localStorage.removeItem('uid');
  router.push('/login');
}
</script>
